#pragma once

#include "UMLStateShape.h"

#include "../uml/State.h"

namespace uml {

const bool UMLStateShape::isTabbed_default_ = false;
UMLStateShape::UMLStateShape(const QString& umlType)
    : UMLCompartmentableShape(umlType) {}

void UMLStateShape::fromJson(const QJsonObject& json, QStringList& errorList) {
    if (json.isEmpty()) {
        return;
    }

    UMLCompartmentableShape::fromJson(json, errorList);
    isTabbed_ = json.value("isTabbed").toBool(isTabbed_default_);
    JsonSerializable::fromJsonArray(modelElements_, "modelElements", json, errorList);
}

void UMLStateShape::toJson(QJsonObject& json) {
    UMLCompartmentableShape::toJson(json);
    if (isTabbed_ != isTabbed_default_) {
        json.insert("isTabbed", isTabbed_);
    }
    JsonSerializable::toJsonArray(modelElements_, "modelElements", json);
}

/// <summary>
/// isTabbed getter
/// </summary>
bool UMLStateShape::isTabbed() const {
    return isTabbed_;
}

/// <summary>
/// isTabbed setter
/// </summary>
void UMLStateShape::setIsTabbed(bool value) {
    isTabbed_ = value;
}

/// <summary>
/// modelElements getter
/// </summary>
vector<shared_ptr<State>>& UMLStateShape::modelElements() {
    return modelElements_;
}

} // namespace uml
